<template>
  <a-card :bordered="false">
    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        :scroll="{ x: true }"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
      >
      </a-table>
    </div>
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction } from '@api/manage'

export default {
  name: 'HfPurchaseinputOrderDetailList',
  mixins: [JeecgListMixin],
  components: {},
  props: {
    mainId: {
      type: String,
      default: '',
      required: false
    }
  },
  watch: {
    mainId: {
      immediate: true,
      handler(val) {
        debugger
        if (!this.mainId) {
          this.clearList()
        } else {
          this.queryParam['orderId'] = val
          this.loadTableData()
        }
      }
    }
  },
  data() {
    return {
      description: '采购单入库详细页面',
      orderId: '',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '物料代码',
          align: 'center',
          dataIndex: 'materialCode'
        },
        {
          title: '物料名称',
          align: 'center',
          dataIndex: 'materialName'
        },
        {
          title: '规格型号',
          align: 'center',
          dataIndex: 'sap'
        },
        {
          title: '单位',
          align: 'center',
          dataIndex: 'unit'
        },
        {
          title: '已入库数量',
          align: 'center',
          dataIndex: 'number'
        },
        {
          title: '需进货数量',
          align: 'center',
          dataIndex: 'totalNumber'
        }
      ],
      url: {
        list: '/purchase/hfPurchaseInput/listHfPurchaseinputOrderDetail'
      },
      dictOptions: {
        supplier: [],
        purchaseType: [],
        sourceType: [],
        isRed: []
      },
      superFieldList: []
    }
  },

  created() {},
  computed: {},
  methods: {
    initDictConfig() {},
    openlist(record) {
      debugger
      const that = this
      this.orderId = record.parentId
      if (this.orderId != undefined) {
        debugger
        this.$nextTick(() => {
          that.queryParam.orderId = this.orderId
          that.loadTableData()
        })
      }
    },
    loadTableData() {
      debugger
      this.ipagination.current = 1
      this.dataSource = []
      var params = this.getQueryParams() //查询条件
      this.loading = true
      getAction(this.url.list, params)
        .then(res => {
          if (res.success) {
            debugger
            this.dataSource = res.result.records || res.result
            if (res.result.total) {
              this.ipagination.total = res.result.total
            } else {
              this.ipagination.total = 0
            }
          } else {
            this.$message.warning(res.message)
          }
        })
        .finally(() => {
          this.loading = false
        })
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
